#define DEBUG
#include <cstdio>

using namespace std;

const int maxn=100000;

int max(int a, int b) {
  return a>b ? a : b ;
}

int main() {
  freopen("rotate.in", "r", stdin);
  freopen("rotate.out", "w", stdout);

  static int a[maxn+1];
  int n, all=0;
  scanf("%d", &n);
  for (int i=1; i<=n; i++) {
    scanf("%d", a+i);
    all += a[i]==i;
  }

  int ans=all;
  for (int i=1; i<=n; i++) {
    int now=all;
    for (int j=1; i-j>0 && i+j<=n; j++) {
      now = now - (a[i-j]==i-j) - (a[i+j]==i+j) + (a[i-j]==i+j) + (a[i+j]==i-j);
      ans = max(ans, now);
    }
  }
  for (int i=1; i<=n; i++) {
    int now=all;
    for (int j=1; i-j>0 && i+j-1<=n; j++) {
      now = now - (a[i-j]==i-1) - (a[i+j-1]==i+j-1) + (a[i-j]==i+j-1) + (a[i+j-1]==i-j);
      ans = max(ans, now);
    }
  }

  printf("%d", ans);

  fclose(stdin);
  fclose(stdout);
  return 0;
}
